<template>
    <div>
        如何获取span 这个dom
        <span ref="refSpan">span</span>
        <p>
            <button @click="getSpan">getSpan</button>
        </p>
    </div>
</template>

<script>
import { onMounted, ref } from 'vue'

export default {
    // mounted () {
    //     console.log(this.$refs.refSpan)
    // }
    setup () {
        const refSpan = ref(null)

        onMounted(()=>{
            console.log('onMounted', refSpan.value.innerHTML)
        })

        const getSpan = () => {
            console.log(refSpan.value.innerHTML)
        }

        return { refSpan, getSpan }
    }
}
</script>